<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="../css/element-plus.index.css">
    <link rel="stylesheet" href="../css/login.css">
    <script type="text/javascript" src="../js/vue.global.3.2.39.js"></script>
    <script type="text/javascript" src="../js/element-plus.2.2.15.js"></script>
    <script type="text/javascript" src="../js/element_plus_icons.2.0.9.js"></script>
    <script type="text/javascript" src="../js/axios.min.0.24.0.js"></script>
    <style>
        .el-form-item__error{
            color:yellow;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="login-box">
        <h1>基于SpringBoot的鲜花管理用户系统</h1>
        <el-form status-icon label-width="120px" ref="loginForm" :rules="formRule" :model="customersInfo">
            <el-form-item label="账号:" prop="adminAccount">
                <el-input autocomplete="off" style="width: 200px;" v-model="customersInfo.cst_mobile" maxlength="50"></el-input>
            </el-form-item>
            <el-form-item label="密码:" prop="adminPwd">
                <el-input type="password" autocomplete="off" style="width: 200px;" v-model="customersInfo.cst_pwd">
                </el-input>
            </el-form-item>
            <!--<el-form-item label="验证码:" prop="code">
                <el-input autocomplete="off" style="width: 120px;margin-right: 5px;" v-model="customersInfo.code" maxlength="4"></el-input>
                <img :src="codeImgSrc" @click="refreshCode"/>
            </el-form-item>-->
            <div style="display: flex; align-items: center;">
                <el-button type="primary" @click="login" style="width: 200px;">登录</el-button>
                <el-button type="sucessful" style="width: 200px; margin-left: 10px;">
                    <a href="../index.html" style="color: #409EFF; text-decoration: none;">转到管理员登录</a>
                </el-button>
            </div>
        </el-form>
    </div>
    <div class="bottom">©2024  XXXXXXXXXXXX<a href="javascript:;" target="_blank">关于</a>
        <span>备案号: 陕ICP备2024041473号</span><img
                width="13" height="16" src="../img/copy_right_24.png"/></div>
    <div class="screenbg">
        <ul>
            <li>
                <a href="javascript:void(0);"><img src="../img/bg_login.png"></a>
            </li>
        </ul>
    </div>
</div>
<script src="../js/common.js"></script>
<script type="text/javascript">
    const options = {
        data() {
            return {
                customersInfo:{
                    cst_mobile: '17663985133',
                    cst_pwd: '123456'
                },
                formRule:{
                    cst_mobile:[
                        {required:true,message:'请输入你的账号!',trigger:'blur'},
                        {min:2,max:50,message:'输入的账号长度不符合要求!',trigger:'blur'}
                    ],
                    cst_pwd:[
                        {required:true,message:'请输入你的密码!',trigger:'blur'},
                        {min:2,max:50,message:'输入的密码长度不符合要求!',trigger:'blur'}
                    ]
                },
                codeImgSrc: SERVER_BASE_URL+'/code'
            };
        },
        methods: {
            login() {
                this.$refs['loginForm'].validate(valid=>{
                    if(valid){
                        //发送请求
                        axios.post("/user/login",this.customersInfo).then(resp=>{
                            if(resp){
                                //保存用户对象信息
                                sessionStorage.setItem('currentUser',JSON.stringify(resp));
                                //登录成功后才可以跳转到主页
                                window.location.href = "./userMain.html";
                            }
                        });
                    }
                });
            },
            refreshCode(){
                let d=new Date();
                this.codeImgSrc=SERVER_BASE_URL+'/code?'+d.getTime();
            }
        }
    };
    const app = Vue.createApp(options);
    app.use(ElementPlus);
    for (const [iconName, iconComp] of Object.entries(ElementPlusIconsVue)) {
        if (iconName == 'Menu') {
            app.component('IconMenu', iconComp);
        } else {
            app.component(iconName, iconComp);
        }
    }
    const vm = app.mount("#app");
</script>
</body>
</html>